package web.mb;

import java.util.List;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import metier.entities.Help;

import metier.sess.IHelpLocal;

@ManagedBean
@RequestScoped
public class HelpMB {

	@EJB
	private IHelpLocal metierh;

	private Integer Id;
	private Help help = new Help();

	public Integer getId() {
		return Id;
	}

	public void setId(Integer id) {
		Id = id;
	}

	public Help getHelp() {
		return help;
	}

	public void setHelp(Help help) {
		this.help = help;
	}

	public String Ajouter() {

		metierh.addHelp(help);
		return "ManageHelp.xhtml";
	}

	public String edit(Integer Id) {
		this.Id = Id;
		Help d = metierh.getHelp(Id);
		this.help.setPage(d.getPage());
		this.help.setTopic(d.getTopic());
		this.help.setContents(d.getContents());
		return "EditHelp.xhtml";
	}

	public String view(Integer Id) {
		this.Id = Id;
		Help d = metierh.getHelp(Id);
		this.help.setPage(d.getPage());
		this.help.setTopic(d.getTopic());
		this.help.setContents(d.getContents());
		return "ViewHelp.xhtml";
	}

	public String Modifier() {
		Help d = metierh.getHelp(Id);

		d.setPage(help.getPage());
		d.setTopic(help.getTopic());
		d.setContents(help.getContents());
		metierh.updateHelp(d);
		return "ManageHelp.xhtml";
	}

	public String Supprimer(Integer Id) {
		metierh.deleteHelp(Id);
		return "succes";
	}

	public List<Help> getListHelps() {
		return metierh.getAllHelp();
	}

}
